using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace RESTAgent.BasicMediaTypes.Hal {
    public class HalPath {
        private Regex _PathRegex = new Regex(@"/?(\w+)(?:\[(\d+)\])?");
        public List<Segment> Segments = new List<Segment>();

        public HalPath(string path) {
            var matches = _PathRegex.Matches(path);
            foreach (Match match in matches) {
                var segment = new Segment {Rel = match.Groups[1].Value, Name = match.Groups[2].Value};
                Segments.Add(segment);
            }
        }

        public class Segment {
            public string Rel;
            public string Name = null;
        }
    }
}